import { log } from 'console'
import React, { Children } from 'react'

type Props = {}

const App = (props: Props) => {
  const arr=[2,1,4,3]   //要排序的数组
  arr.sort((a,b)=>a-b)//使用sort方法排序
  console.log(arr);
 const brr=[1,6,7,9] //计算差值最大数组

 brr.forEach((item,index)=>{//循环遍历数组,计算最大差值
    
  console.log(item);

 })
 
 const crr=[brr[0]-brr[1],brr[0]-brr[2],brr[0]-brr[3],brr[1]-brr[0],brr[1]-brr[2],brr[1]-brr[3],brr[2]-brr[0],brr[2]-brr[1],brr[2]-brr[2],brr[2]-brr[3],
  brr[3]-brr[0],brr[3]-brr[1],brr[3]-brr[2] //逐个算出每一个的差值最后判断大小
]
  
 const max=crr[10]
   
 console.log(max);
  return (
    <div>
      <h3>排序前数组：[2,1,4,3]</h3>
      <h3>排序后数组：{arr}</h3>
      <h1>最大差值为：{max}</h1>
    </div>
  )
}

export default App